<?php
	session_start(); 
	include('../user_type/system.php');
	include('../access/login_functions.php');
	include("../access/opendb.php"); 
	$_SESSION['restricted'] = true;
	check_logged_in();	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }	if ($_SESSION['Status'] == "NewModerator") { send_to_page('firstTimeLogin.php'); }
	
	$complaintID = intval($_POST['complaintID']);
	$fromUID = intval($_POST['fromUID']);
	$toUID = intval($_POST['toUID']);
	$complaint = $_POST['complaint'];
	$decision = $_POST['decision'];
	$date = date("Y-m-d");
	
	if ($decision == "Honor Complaint")
	{
		// deduct points from $toUID
		$credits = System::reduceCredits($toUID);
		
		if ($credits > 0)		// send warning to user
			$warning = System::warnUser($toUID);
		elseif ($credits < 0)	// ban user
			$warning = System::pendingBan($toUID);
		
		// add warning to warning table
		$query = mysql_query("INSERT INTO warning_table (UID, warning, date) VALUES($toUID, $warning, $date)");
		$warnLog = "($date) Complaint #$complaintID. [$decision] -- Reduced credit from USER$toUID for complaint, made by USER#$fromUID:\n\n$complaint\n\n";
	}
	
	// if Deny Complaint, do nothing
	mysql_query("UPDATE complaint_table SET resolved=\"yes\" WHERE ID=$complaintID");
	
		
	include("../access/closedb.php");
	send_to_page("../" . $_SESSION['curPage']);
?>